import axios from "@/utils/dbrequst";
enum Api {
  news = "/news",
}
export const getNewsList = () => {
  return axios.get(Api.news);
};
export const getNewsPage = ({
  _page,
  _limit,
}: {
  _page: number;
  _limit: number;
}) => {
  return axios.get(`${Api.news}?_page=${_page}&_limit=${_limit}`);
};
export const getNewsItem = (id: number) => {
  return axios.get(`${Api.news}?id=${id}`);
};
export const deleteNews = (id: number) => {
  return axios({ method: "delete", url: `${Api.news}/${id}` });
};
export const addNews = (data: {
  id: number;
  title: string;
  imgUrl: string;
}) => {
  return axios({ method: "post", url: `/news`, data });
};
export const putGame = (data: {
  id: number;
  title: string;
  imgUrl: string;
}) => {
  console.log("daddd", data);
  const reqData = {
    title: data.title,
    imgUrl: data.imgUrl,
  };
  return axios({ method: "put", url: `/news/${data.id}`, data: reqData });
};
export const getTitle = (title: string) => {
  return axios({
    method: "get",
    url: `${Api.news}?title_like=${title}`,
  });
};
